<template>
    <div>
        <span>组件B接收到A传递的数据：{{num}}</span>
    </div>
</template>
<script>
// import pubsub from 'pubsub-js'
export default {
    data(){
        return{
            num:0
        }
    },
    mounted(){
        // 订阅消息
       this.pubId  =  this.PubSub.subscribe('helloFn',(eventName,data)=>{
            this.num = data

        })
    },
    beforeDestroy(){
       // 取消订阅
        this.PubSub.unsubscribe(this.pubId)
    }
}
</script>